/* 容器基础样式 - 解决布局不协调问题 */
.diagram-container {
    position: relative;
    width: 2000px; /* 足够大的画布空间 */
    height: 1600px;
    margin: 0;
    background: #1a1e2d;
    background-image:
            radial-gradient(circle at 20% 30%, rgba(106, 17, 203, 0.15) 0%, transparent 25%),
            radial-gradient(circle at 80% 70%, rgba(76, 161, 175, 0.15) 0%, transparent 25%),
            linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 50px 50px;
    border-radius: 16px;
    box-shadow:
            0 15px 40px rgba(0, 0, 0, 0.4),
            inset 0 0 30px rgba(255,255,255,0.03);
    overflow: hidden;
}

/* 外层容器样式 - 确保居中显示 */
.diagram-wrapper {
    position: relative;
    max-width: 1200px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    background-color: #141724;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 740px;
}

/* 控制按钮样式 */
.diagram-controls {
    position: absolute;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.control-btn {
    width: clamp(36px, 5vw, 44px);
    height: clamp(36px, 5vw, 44px);
    border-radius: 50%;
    background: rgba(30, 34, 51, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.3),
            inset 0 1px 1px rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(40, 45, 66, 0.9);
    color: white;
    transform: translateY(-3px);
    box-shadow:
            0 6px 16px rgba(0, 0, 0, 0.4),
            inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.control-btn:active {
    transform: translateY(-1px);
}

/* 背景动态装饰 */
.diagram-bg-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
            radial-gradient(circle at 30% 40%, rgba(106, 17, 203, 0.05) 0%, transparent 40%),
            radial-gradient(circle at 70% 60%, rgba(76, 161, 175, 0.05) 0%, transparent 40%);
    background-size: 120% 120%, 120% 120%;
    background-position: 0 0, 0 0;
    animation: bgFloat 30s infinite ease-in-out;
    pointer-events: none;
}

/* 节点容器样式 */
.node-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center;
    padding: 4px;
    opacity: 0;
}

/* 节点进入动画 */
@keyframes nodeEnter {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.node-container:hover {
    transform: scale(1.12);
    z-index: 5 !important;
}

.node-container:active {
    transform: scale(1.08);
}

/* 选中节点样式 */
.node-container.selected .main-node,
.node-container.selected .node {
    box-shadow:
            0 0 20px rgba(255, 215, 0, 0.8),
            0 8px 30px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

/* 主节点样式 */
.main-node {
    width: clamp(120px, 15vw, 150px);
    height: clamp(75px, 10vw, 95px);
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: clamp(14px, 3vw, 16px);
    box-shadow:
            0 0 15px rgba(106, 17, 203, 0.6),
            0 8px 25px rgba(0, 0, 0, 0.3),
            inset 0 1px 3px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: pulse 4s infinite ease-in-out;
    text-align: center;
    padding: 0 10px;
}

/* 主节点光效 */
.main-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shine 4s infinite linear;
    transform: skewX(-20deg);
}

.main-node::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6a11cb, #2575fc);
    z-index: -1;
    filter: blur(8px);
    opacity: 0.7;
    animation: glow 6s infinite alternate;
}

/* 普通节点样式 */
.node {
    width: clamp(100px, 12vw, 135px);
    height: clamp(60px, 8vw, 75px);
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(12px, 2.5vw, 14px);
    box-shadow:
            0 4px 15px rgba(0, 0, 0, 0.25),
            inset 0 1px 2px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    padding: 0 10px;
    text-align: center;
}

.node::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shine 6s infinite linear;
    transform: skewX(-20deg);
}

/* 权重节点样式 */
.weight-node {
    background: linear-gradient(135deg, #00b42a 0%, #008141 100%);
    box-shadow:
            0 0 15px rgba(0, 180, 42, 0.5),
            0 6px 20px rgba(0, 0, 0, 0.25);
}

.weight-node::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 2px;
    width: 8px;
    height: 8px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    transform: translateY(-50%);
    box-shadow: 0 0 5px rgba(255,255,255,0.8);
}

/* 图标样式 */
.main-icon {
    margin-right: 8px;
    font-size: clamp(16px, 3vw, 20px);
    opacity: 0.9;
    animation: iconPulse 3s infinite alternate;
}

.icon {
    margin-right: 8px;
    font-size: clamp(14px, 2.5vw, 16px);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.node:hover .icon {
    transform: scale(1.2);
    opacity: 1;
}

/* 连接线样式 */
.connector-svg {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

.connector {
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 2.5px;
    fill: none;
    transition: all 0.4s ease;
    stroke-linecap: round;
}

.main-connection {
    stroke: rgba(106, 17, 203, 0.6);
    stroke-width: 3px;
}

.connector.highlight {
    stroke: rgba(255, 215, 0, 0.8);
    stroke-width: 3.5px;
    animation: linePulse 2s infinite;
}

/* 箭头样式 */
.arrow-fill {
    fill: rgba(255, 255, 255, 0.6);
    stroke: none;
    animation: arrowPulse 4s infinite;
}

.main-arrow-fill {
    fill: rgba(106, 17, 203, 0.8);
    stroke: none;
    animation: arrowPulse 3s infinite;
}

/* 连接粒子样式 */
.connection-particle {
    animation: particleFade 3s infinite;
}

/* 动画定义 */
@keyframes shine {
    0% { left: -100%; }
    20%, 100% { left: 100%; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes glow {
    0% { opacity: 0.5; filter: blur(8px); }
    100% { opacity: 0.8; filter: blur(10px); }
}

@keyframes iconPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

@keyframes arrowPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
}

@keyframes particleFade {
    0% { opacity: 0; r: 2px; }
    30% { opacity: 1; r: 3px; }
    70% { opacity: 1; r: 3px; }
    100% { opacity: 0; r: 2px; }
}

@keyframes bgFloat {
    0% { background-position: 0 0, 0 0; }
    50% { background-position: 20% 10%, -10% 15%; }
    100% { background-position: 0 0, 0 0; }
}

@keyframes linePulse {
    0%, 100% { stroke-width: 3.5px; opacity: 0.8; }
    50% { stroke-width: 4px; opacity: 1; }
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .diagram-wrapper {
        width: 95%;
    }
}

@media (max-width: 768px) {
    .diagram-container {
        width: 1600px;
        height: 1200px;
    }

    .connector {
        stroke-width: 2px;
    }

    .main-connection {
        stroke-width: 2.5px;
    }

    .node-container {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .control-btn {
        width: 36px;
        height: 36px;
    }

    .diagram-controls {
        gap: 8px;
    }

    .diagram-container {
        width: 1400px;
        height: 1000px;
    }
}

/* 横屏移动设备优化 */
@media (max-height: 450px) and (orientation: landscape) {
    .diagram-container {
        width: 1400px;
        height: 900px;
    }

    .main-node {
        width: 100px;
        height: 60px;
        font-size: 12px;
    }

    .node {
        width: 85px;
        height: 50px;
        font-size: 11px;
    }
}
